﻿@using EasyCourse.Model;
@{
    Layout = null;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    string para = "CourseId=" + pageInfo.CourseId;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>新增@(ViewData["TypeName"])</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
    <link href="~/Css/uploadify.css" rel="stylesheet" />
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @pageInfo.CourseName<br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @*导航菜单*@
    @Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 4)
    <div class="container mainwrap">
        <div class="row">
            @Html.Partial("~/Views/Share/PublicResourceInfoMenu_Add.cshtml", this.ViewData)
            <div class="col-xs-10">
                <div class="panel panel-default mainwrap-part">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <ol class="breadcrumb">
                                <li>资源管理</li>
                                <li class="active">新增@(ViewData["TypeName"])</li>
                            </ol>
                        </h3>
                    </div>
                    <div class="panel-body" style="height: 400px;">
                        <div class="row">
                            <form role="form" id="frm" class="form-horizontal">
                                @Html.Hidden("CourseId")
                                @Html.Hidden("TypeCode")
                                <div class="form-group clearfix">
                                    <label for="firstname" class="col-xs-2 control-label">@(ViewData["TypeName"])标题：</label>
                                    <div class="col-xs-4">
                                        <input type="text" class="form-control input-md" name="Title" placeholder="请输入资源标题">
                                    </div>
                                </div>
                                <div class="form-group clearfix">
                                    <label for="firstname" class="col-xs-2 control-label">@(ViewData["TypeName"])附件：</label>
                                    <div class="col-xs-4">
                                        <input type="hidden" id="FilePath" name="FilePath" />
                                        <input name="FileName" id="JfileName" class="form-control mb10" readonly="readonly" />                                            
                                        <input id="file_upload" name="file_upload" type="file" class="form-control input-sm">
                                    </div>
                                </div>
                                <div class="form-group clearfix">
                                    <div class="col-xs-offset-2 col-xs-10">
                                        <button type="button" onclick="autoSubmit('frm')" class="btn btn-success">保存</button>
                                        <button type="button" onclick="history.go(-1)" class="btn btn-success btn-md"><span class="glyphicon glyphicon-arrow-left"></span>返回</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")

    <script src="~/Content/jquery.form.js"></script>
    <script type="text/javascript" src="../Js/uploadToggle.js"></script>
    <script>
        $(function () {
            //上传文件
            var _attachmentUrl = null;


            uploadToggle('/Base/UpLoad', {  'fileType': 'OtherFile' }, function (file, data) {
            var json = $.parseJSON(data);
            if (json.result) {
                        _attachmentUrl = json.message; //文件保存的地址
                    $("#JfileName").val(file.name);
                    $("#FilePath").val( _attachmentUrl);
            }
            else {
                showTips.open(json.message);
            }
            }); 
        });


        var t = true;
        function autoSubmit(frmId) {
            var postData = $("#" + frmId).formSerialize();
            var url = "@Url.Action("ResourceInfoAdd", "ResourceInfo")";
            var options = {
                type: 'POST',
                data: postData,
                url: url,
                async: false,
                cache: false,
                success: function (data) {
                    if (data.result) {
                        showTips.open("添加成功");
                        $("#frm")[0].reset();
                    }
                    else {
                        showTips.open(data.message);
                    }
                }

            }
            if (t) {
                t = false;
                $.ajax(options);
                t = true;
            }
        };
    </script>
</body>
</html>
